<?php
	/**
	 * This is a MetaControl class, providing a QForm or QPanel access to event handlers
	 * and QControls to perform the Create, Edit, and Delete functionality
	 * of the MantisEmailTable class.  This code-generated class
	 * contains all the basic elements to help a QPanel or QForm display an HTML form that can
	 * manipulate a single MantisEmailTable object.
	 *
	 * To take advantage of some (or all) of these control objects, you
	 * must create a new QForm or QPanel which instantiates a MantisEmailTableMetaControl
	 * class.
	 *
	 * Any and all changes to this file will be overwritten with any subsequent
	 * code re-generation.
	 *
	 * @package My QCubed Application
	 * @subpackage MetaControls
	 * @property-read MantisEmailTable $MantisEmailTable the actual MantisEmailTable data class being edited
	 * @property QLabel $EmailIdControl
	 * @property-read QLabel $EmailIdLabel
	 * @property QTextBox $EmailControl
	 * @property-read QLabel $EmailLabel
	 * @property QTextBox $SubjectControl
	 * @property-read QLabel $SubjectLabel
	 * @property QTextBox $MetadataControl
	 * @property-read QLabel $MetadataLabel
	 * @property QTextBox $BodyControl
	 * @property-read QLabel $BodyLabel
	 * @property QIntegerTextBox $SubmittedControl
	 * @property-read QLabel $SubmittedLabel
	 * @property-read string $TitleVerb a verb indicating whether or not this is being edited or created
	 * @property-read boolean $EditMode a boolean indicating whether or not this is being edited or created
	 */

	class MantisEmailTableMetaControlGen extends QBaseClass {
		// General Variables
		/**
		 * @var MantisEmailTable objMantisEmailTable
		 * @access protected
		 */
		protected $objMantisEmailTable;
		/**
		 * @var QForm|QControl objParentObject
		 * @access protected
		 */
		protected $objParentObject;
		/**
		 * @var string strTitleVerb
		 * @access protected
		 */
		protected $strTitleVerb;
		/**
		 * @var boolean blnEditMode
		 * @access protected
		 */
		protected $blnEditMode;

		// Controls that allow the editing of MantisEmailTable's individual data fields
		/**
		 * @var QLabel lblEmailId
		 * @access protected
		 */
		protected $lblEmailId;
		/**
		 * @var QTextBox txtEmail
		 * @access protected
		 */
		protected $txtEmail;
		/**
		 * @var QTextBox txtSubject
		 * @access protected
		 */
		protected $txtSubject;
		/**
		 * @var QTextBox txtMetadata
		 * @access protected
		 */
		protected $txtMetadata;
		/**
		 * @var QTextBox txtBody
		 * @access protected
		 */
		protected $txtBody;
		/**
		 * @var QIntegerTextBox txtSubmitted
		 * @access protected
		 */
		protected $txtSubmitted;

		// Controls that allow the viewing of MantisEmailTable's individual data fields
		/**
		 * @var QLabel lblEmail
		 * @access protected
		 */
		protected $lblEmail;
		/**
		 * @var QLabel lblSubject
		 * @access protected
		 */
		protected $lblSubject;
		/**
		 * @var QLabel lblMetadata
		 * @access protected
		 */
		protected $lblMetadata;
		/**
		 * @var QLabel lblBody
		 * @access protected
		 */
		protected $lblBody;
		/**
		 * @var QLabel lblSubmitted
		 * @access protected
		 */
		protected $lblSubmitted;

		// QListBox Controls (if applicable) to edit Unique ReverseReferences and ManyToMany References

		// QLabel Controls (if applicable) to view Unique ReverseReferences and ManyToMany References


		/**
		 * Main constructor.  Constructor OR static create methods are designed to be called in either
		 * a parent QPanel or the main QForm when wanting to create a
		 * MantisEmailTableMetaControl to edit a single MantisEmailTable object within the
		 * QPanel or QForm.
		 *
		 * This constructor takes in a single MantisEmailTable object, while any of the static
		 * create methods below can be used to construct based off of individual PK ID(s).
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this MantisEmailTableMetaControl
		 * @param MantisEmailTable $objMantisEmailTable new or existing MantisEmailTable object
		 */
		 public function __construct($objParentObject, MantisEmailTable $objMantisEmailTable) {
			// Setup Parent Object (e.g. QForm or QPanel which will be using this MantisEmailTableMetaControl)
			$this->objParentObject = $objParentObject;

			// Setup linked MantisEmailTable object
			$this->objMantisEmailTable = $objMantisEmailTable;

			// Figure out if we're Editing or Creating New
			if ($this->objMantisEmailTable->__Restored) {
				$this->strTitleVerb = QApplication::Translate('Edit');
				$this->blnEditMode = true;
			} else {
				$this->strTitleVerb = QApplication::Translate('Create');
				$this->blnEditMode = false;
			}
		 }

		/**
		 * Static Helper Method to Create using PK arguments
		 * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
		 * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
		 * static helper methods.  Finally, specify a CreateType to define whether or not we are only allowed to
		 * edit, or if we are also allowed to create a new one, etc.
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this MantisEmailTableMetaControl
		 * @param integer $intEmailId primary key value
		 * @param QMetaControlCreateType $intCreateType rules governing MantisEmailTable object creation - defaults to CreateOrEdit
 		 * @return MantisEmailTableMetaControl
		 */
		public static function Create($objParentObject, $intEmailId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			// Attempt to Load from PK Arguments
			if (strlen($intEmailId)) {
				$objMantisEmailTable = MantisEmailTable::Load($intEmailId);

				// MantisEmailTable was found -- return it!
				if ($objMantisEmailTable)
					return new MantisEmailTableMetaControl($objParentObject, $objMantisEmailTable);

				// If CreateOnRecordNotFound not specified, throw an exception
				else if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound)
					throw new QCallerException('Could not find a MantisEmailTable object with PK arguments: ' . $intEmailId);

			// If EditOnly is specified, throw an exception
			} else if ($intCreateType == QMetaControlCreateType::EditOnly)
				throw new QCallerException('No PK arguments specified');

			// If we are here, then we need to create a new record
			return new MantisEmailTableMetaControl($objParentObject, new MantisEmailTable());
		}

		/**
		 * Static Helper Method to Create using PathInfo arguments
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this MantisEmailTableMetaControl
		 * @param QMetaControlCreateType $intCreateType rules governing MantisEmailTable object creation - defaults to CreateOrEdit
		 * @return MantisEmailTableMetaControl
		 */
		public static function CreateFromPathInfo($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			$intEmailId = QApplication::PathInfo(0);
			return MantisEmailTableMetaControl::Create($objParentObject, $intEmailId, $intCreateType);
		}

		/**
		 * Static Helper Method to Create using QueryString arguments
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this MantisEmailTableMetaControl
		 * @param QMetaControlCreateType $intCreateType rules governing MantisEmailTable object creation - defaults to CreateOrEdit
		 * @return MantisEmailTableMetaControl
		 */
		public static function CreateFromQueryString($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			$intEmailId = QApplication::QueryString('intEmailId');
			return MantisEmailTableMetaControl::Create($objParentObject, $intEmailId, $intCreateType);
		}



		///////////////////////////////////////////////
		// PUBLIC CREATE and REFRESH METHODS
		///////////////////////////////////////////////

		/**
		 * Create and setup QLabel lblEmailId
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblEmailId_Create($strControlId = null) {
			$this->lblEmailId = new QLabel($this->objParentObject, $strControlId);
			$this->lblEmailId->Name = QApplication::Translate('Email Id');
			if ($this->blnEditMode)
				$this->lblEmailId->Text = $this->objMantisEmailTable->EmailId;
			else
				$this->lblEmailId->Text = 'N/A';
			return $this->lblEmailId;
		}

		/**
		 * Create and setup QTextBox txtEmail
		 * @param string $strControlId optional ControlId to use
		 * @return QTextBox
		 */
		public function txtEmail_Create($strControlId = null) {
			$this->txtEmail = new QTextBox($this->objParentObject, $strControlId);
			$this->txtEmail->Name = QApplication::Translate('Email');
			$this->txtEmail->Text = $this->objMantisEmailTable->Email;
			$this->txtEmail->Required = true;
			$this->txtEmail->MaxLength = MantisEmailTable::EmailMaxLength;
			return $this->txtEmail;
		}

		/**
		 * Create and setup QLabel lblEmail
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblEmail_Create($strControlId = null) {
			$this->lblEmail = new QLabel($this->objParentObject, $strControlId);
			$this->lblEmail->Name = QApplication::Translate('Email');
			$this->lblEmail->Text = $this->objMantisEmailTable->Email;
			$this->lblEmail->Required = true;
			return $this->lblEmail;
		}

		/**
		 * Create and setup QTextBox txtSubject
		 * @param string $strControlId optional ControlId to use
		 * @return QTextBox
		 */
		public function txtSubject_Create($strControlId = null) {
			$this->txtSubject = new QTextBox($this->objParentObject, $strControlId);
			$this->txtSubject->Name = QApplication::Translate('Subject');
			$this->txtSubject->Text = $this->objMantisEmailTable->Subject;
			$this->txtSubject->Required = true;
			$this->txtSubject->MaxLength = MantisEmailTable::SubjectMaxLength;
			return $this->txtSubject;
		}

		/**
		 * Create and setup QLabel lblSubject
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblSubject_Create($strControlId = null) {
			$this->lblSubject = new QLabel($this->objParentObject, $strControlId);
			$this->lblSubject->Name = QApplication::Translate('Subject');
			$this->lblSubject->Text = $this->objMantisEmailTable->Subject;
			$this->lblSubject->Required = true;
			return $this->lblSubject;
		}

		/**
		 * Create and setup QTextBox txtMetadata
		 * @param string $strControlId optional ControlId to use
		 * @return QTextBox
		 */
		public function txtMetadata_Create($strControlId = null) {
			$this->txtMetadata = new QTextBox($this->objParentObject, $strControlId);
			$this->txtMetadata->Name = QApplication::Translate('Metadata');
			$this->txtMetadata->Text = $this->objMantisEmailTable->Metadata;
			$this->txtMetadata->Required = true;
			$this->txtMetadata->TextMode = QTextMode::MultiLine;
			return $this->txtMetadata;
		}

		/**
		 * Create and setup QLabel lblMetadata
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblMetadata_Create($strControlId = null) {
			$this->lblMetadata = new QLabel($this->objParentObject, $strControlId);
			$this->lblMetadata->Name = QApplication::Translate('Metadata');
			$this->lblMetadata->Text = $this->objMantisEmailTable->Metadata;
			$this->lblMetadata->Required = true;
			return $this->lblMetadata;
		}

		/**
		 * Create and setup QTextBox txtBody
		 * @param string $strControlId optional ControlId to use
		 * @return QTextBox
		 */
		public function txtBody_Create($strControlId = null) {
			$this->txtBody = new QTextBox($this->objParentObject, $strControlId);
			$this->txtBody->Name = QApplication::Translate('Body');
			$this->txtBody->Text = $this->objMantisEmailTable->Body;
			$this->txtBody->Required = true;
			$this->txtBody->TextMode = QTextMode::MultiLine;
			return $this->txtBody;
		}

		/**
		 * Create and setup QLabel lblBody
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblBody_Create($strControlId = null) {
			$this->lblBody = new QLabel($this->objParentObject, $strControlId);
			$this->lblBody->Name = QApplication::Translate('Body');
			$this->lblBody->Text = $this->objMantisEmailTable->Body;
			$this->lblBody->Required = true;
			return $this->lblBody;
		}

		/**
		 * Create and setup QIntegerTextBox txtSubmitted
		 * @param string $strControlId optional ControlId to use
		 * @return QIntegerTextBox
		 */
		public function txtSubmitted_Create($strControlId = null) {
			$this->txtSubmitted = new QIntegerTextBox($this->objParentObject, $strControlId);
			$this->txtSubmitted->Name = QApplication::Translate('Submitted');
			$this->txtSubmitted->Text = $this->objMantisEmailTable->Submitted;
			$this->txtSubmitted->Required = true;
			return $this->txtSubmitted;
		}

		/**
		 * Create and setup QLabel lblSubmitted
		 * @param string $strControlId optional ControlId to use
		 * @param string $strFormat optional sprintf format to use
		 * @return QLabel
		 */
		public function lblSubmitted_Create($strControlId = null, $strFormat = null) {
			$this->lblSubmitted = new QLabel($this->objParentObject, $strControlId);
			$this->lblSubmitted->Name = QApplication::Translate('Submitted');
			$this->lblSubmitted->Text = $this->objMantisEmailTable->Submitted;
			$this->lblSubmitted->Required = true;
			$this->lblSubmitted->Format = $strFormat;
			return $this->lblSubmitted;
		}



		/**
		 * Refresh this MetaControl with Data from the local MantisEmailTable object.
		 * @param boolean $blnReload reload MantisEmailTable from the database
		 * @return void
		 */
		public function Refresh($blnReload = false) {
			if ($blnReload)
				$this->objMantisEmailTable->Reload();

			if ($this->lblEmailId) if ($this->blnEditMode) $this->lblEmailId->Text = $this->objMantisEmailTable->EmailId;

			if ($this->txtEmail) $this->txtEmail->Text = $this->objMantisEmailTable->Email;
			if ($this->lblEmail) $this->lblEmail->Text = $this->objMantisEmailTable->Email;

			if ($this->txtSubject) $this->txtSubject->Text = $this->objMantisEmailTable->Subject;
			if ($this->lblSubject) $this->lblSubject->Text = $this->objMantisEmailTable->Subject;

			if ($this->txtMetadata) $this->txtMetadata->Text = $this->objMantisEmailTable->Metadata;
			if ($this->lblMetadata) $this->lblMetadata->Text = $this->objMantisEmailTable->Metadata;

			if ($this->txtBody) $this->txtBody->Text = $this->objMantisEmailTable->Body;
			if ($this->lblBody) $this->lblBody->Text = $this->objMantisEmailTable->Body;

			if ($this->txtSubmitted) $this->txtSubmitted->Text = $this->objMantisEmailTable->Submitted;
			if ($this->lblSubmitted) $this->lblSubmitted->Text = $this->objMantisEmailTable->Submitted;

		}



		///////////////////////////////////////////////
		// PROTECTED UPDATE METHODS for ManyToManyReferences (if any)
		///////////////////////////////////////////////





		///////////////////////////////////////////////
		// PUBLIC MANTISEMAILTABLE OBJECT MANIPULATORS
		///////////////////////////////////////////////

		/**
		 * This will save this object's MantisEmailTable instance,
		 * updating only the fields which have had a control created for it.
		 */
		public function SaveMantisEmailTable() {
			try {
				// Update any fields for controls that have been created
				if ($this->txtEmail) $this->objMantisEmailTable->Email = $this->txtEmail->Text;
				if ($this->txtSubject) $this->objMantisEmailTable->Subject = $this->txtSubject->Text;
				if ($this->txtMetadata) $this->objMantisEmailTable->Metadata = $this->txtMetadata->Text;
				if ($this->txtBody) $this->objMantisEmailTable->Body = $this->txtBody->Text;
				if ($this->txtSubmitted) $this->objMantisEmailTable->Submitted = $this->txtSubmitted->Text;

				// Update any UniqueReverseReferences (if any) for controls that have been created for it

				// Save the MantisEmailTable object
				$this->objMantisEmailTable->Save();

				// Finally, update any ManyToManyReferences (if any)
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * This will DELETE this object's MantisEmailTable instance from the database.
		 * It will also unassociate itself from any ManyToManyReferences.
		 */
		public function DeleteMantisEmailTable() {
			$this->objMantisEmailTable->Delete();
		}



		///////////////////////////////////////////////
		// PUBLIC GETTERS and SETTERS
		///////////////////////////////////////////////

		/**
		 * Override method to perform a property "Get"
		 * This will get the value of $strName
		 *
		 * @param string $strName Name of the property to get
		 * @return mixed
		 */
		public function __get($strName) {
			switch ($strName) {
				// General MetaControlVariables
				case 'MantisEmailTable': return $this->objMantisEmailTable;
				case 'TitleVerb': return $this->strTitleVerb;
				case 'EditMode': return $this->blnEditMode;

				// Controls that point to MantisEmailTable fields -- will be created dynamically if not yet created
				case 'EmailIdControl':
					if (!$this->lblEmailId) return $this->lblEmailId_Create();
					return $this->lblEmailId;
				case 'EmailIdLabel':
					if (!$this->lblEmailId) return $this->lblEmailId_Create();
					return $this->lblEmailId;
				case 'EmailControl':
					if (!$this->txtEmail) return $this->txtEmail_Create();
					return $this->txtEmail;
				case 'EmailLabel':
					if (!$this->lblEmail) return $this->lblEmail_Create();
					return $this->lblEmail;
				case 'SubjectControl':
					if (!$this->txtSubject) return $this->txtSubject_Create();
					return $this->txtSubject;
				case 'SubjectLabel':
					if (!$this->lblSubject) return $this->lblSubject_Create();
					return $this->lblSubject;
				case 'MetadataControl':
					if (!$this->txtMetadata) return $this->txtMetadata_Create();
					return $this->txtMetadata;
				case 'MetadataLabel':
					if (!$this->lblMetadata) return $this->lblMetadata_Create();
					return $this->lblMetadata;
				case 'BodyControl':
					if (!$this->txtBody) return $this->txtBody_Create();
					return $this->txtBody;
				case 'BodyLabel':
					if (!$this->lblBody) return $this->lblBody_Create();
					return $this->lblBody;
				case 'SubmittedControl':
					if (!$this->txtSubmitted) return $this->txtSubmitted_Create();
					return $this->txtSubmitted;
				case 'SubmittedLabel':
					if (!$this->lblSubmitted) return $this->lblSubmitted_Create();
					return $this->lblSubmitted;
				default:
					try {
						return parent::__get($strName);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}

		/**
		 * Override method to perform a property "Set"
		 * This will set the property $strName to be $mixValue
		 *
		 * @param string $strName Name of the property to set
		 * @param string $mixValue New value of the property
		 * @return mixed
		 */
		public function __set($strName, $mixValue) {
			try {
				switch ($strName) {
					// Controls that point to MantisEmailTable fields
					case 'EmailIdControl':
						return ($this->lblEmailId = QType::Cast($mixValue, 'QControl'));
					case 'EmailControl':
						return ($this->txtEmail = QType::Cast($mixValue, 'QControl'));
					case 'SubjectControl':
						return ($this->txtSubject = QType::Cast($mixValue, 'QControl'));
					case 'MetadataControl':
						return ($this->txtMetadata = QType::Cast($mixValue, 'QControl'));
					case 'BodyControl':
						return ($this->txtBody = QType::Cast($mixValue, 'QControl'));
					case 'SubmittedControl':
						return ($this->txtSubmitted = QType::Cast($mixValue, 'QControl'));
					default:
						return parent::__set($strName, $mixValue);
				}
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}
	}
?>